<?php
    use User\Model\ActivityRegisterModel;
?>
<!-- page heading start-->
<div class="page-heading">
    <h3>
        报名列表
    </h3>

</div>
<!-- page heading end-->
<div class="row">
    <div class="col-sm-12">
        <section class="panel">
            <header class="panel-heading" style="height: 180px;">
                <form method="get" action="/User/Activityds/register">
                    <input type="hidden" name="actId" value="<?php echo I('get.actId', '', '');?>">
                    <div class="col-sm-4">
                    状态：<select class="form-control" name="status">
                        <option value="0">全部</option>
                        <?php
                            $sta = I('get.status', '', '');
                            foreach(ActivityRegisterModel::get_status() as $key => $status){
                                echo '<option value="' . $key . '"';
                                if($sta == $key){
                                    echo " selected ";
                                }
                                echo '>' . $status . '</option>';
                            }
                        ?>
                        </select>
                    </div>
                    <div class="col-sm-4">
                        手机号码：<input type="text" class="form-control" name="mobile" value="<?php echo I('get.mobile', '', '');?>">
                    </div>
                    <div class="col-sm-4" style="margin-top: 20px;">
                        <input type="submit" class="btn btn-success" value="查询">
                        <input type="button" class="btn btn-default" value="导出" onclick="return download();">
                        <a class="btn btn-default" href="<?php echo '/User/Activityds/registerAdd?actId=' . I('get.actId', '', '');?>">增加</a>
                    </div>
                </form>
            </header>
            <div class="panel-body">
                <table class="table table-hover general-table table-bordered">
                    <thead>
                    <tr>
                        <th width="12%">姓名</th>
                        <th width="10%">手机号码</th>
                        <th width="12%">公司</th>
                        <th width="12%">职位</th>
                        <th width="8%">状态</th>
                        <th width="22%">参加活动</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($list as $val){?>
                    <tr>
                        <td>
                            <span>
                                <?php echo $val['name'];?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo $val['mobile'];?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo $val['company'];?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo $val['position'];?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo ActivityRegisterModel::get_status($val['status']);?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo $val['activity'];?>
                            </span>
                        </td>
                        <td>
                            <p><a class="btn btn-success"
                               href="<?php echo '/User/Activityds/registerUpdate?type=update&regId=' . $val['reg_id'];?>">编辑</a>
                            <a class="btn btn-default" href="#"
                               onclick="<?php echo 'return delete_data(' . $val['reg_id'] .')';?>">删除</a></p>
                            <p><a class="btn btn-info" href="#"
                               onclick="<?php echo 'return pass_data(' . $val['reg_id'] .')';?>">通过</a>
                            <a class="btn btn-warning" href="#"
                               onclick="<?php echo 'return unpass_data(' . $val['reg_id'] .')';?>">不通过</a></p>
                        </td>
                    </tr>
                    <?php }?>

                    </tbody>
                </table>
                <div class="pages">
                    {$page}
                </div>
            </div>
        </section>
    </div>
</div>
<script>
    function delete_data(id){
        $.ajax({
            data:{regId:id},
            dataType:'json',
            url:'/User/Activityds/registerDelete',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
    function pass_data(id){
        $.ajax({
            data:{regId:id},
            dataType:'json',
            url:'/User/Activityds/registerPass',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
    function unpass_data(id){
        $.ajax({
            data:{regId:id},
            dataType:'json',
            url:'/User/Activityds/registerUnpass',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
    function download(){
        var data = $("form").serialize();
        window.location = '/User/Activityds/download?' + data;
        return false;
    }
</script>